import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)


// 静态路由
export const fixedRouter = [{ //整体主页
		path: '/',
		name: 'Home',
		component: Home,
		redirect: '/index/main',
		meta: {
			title: '首页',
			path: "/"
		},
	},
	//登录
	{
		path: '/login',
		name: 'Login',
		component: () => import("../views/Login.vue"),
		meta: {
			title: '登录',
			path: "/login"
		}
	},
	//首页
	{
		path: '/index',
		name: 'Index',
		component: () => import("../views/index/Index.vue"),
		meta: {
			title: '首页',
			path: "/index"
		},
		children: [{
				path: "main",
				name: 'Main',
				component: () => import("../views/index/main.vue"),
				meta: {
					title: '首页',
					path: "/index/main"
				}
			},
			// 空白页面
			{
				path: "/empty",
				name: 'empty',
				component: () => import("../views/index/empty.vue"),
				meta: {
					title: '刷新',
					path: "/empty"
				}
			}
		]
	},
]


//动态路由
export const dynamicRouter = [
	//用户管理
	{
		path: "/user",
		name: "User-manage",
		component: () => import("../views/user-manage/User-manage.vue"),
		meta: {
			title: '用户管理',
			path: "/user"
		},
		children: [{
				path: "member",
				component: () => import("../views/user-manage/vip-manage.vue"), //会员管理
				meta: {
					perms: ['GET /admin/member/list'],
					title: '会员管理',
					path: "/user/member",
					noCache: true
				}
			},
			{
				path: "address",
				component: () => import("../views/user-manage/site-manage.vue"), //收货地址
				meta: {
					perms: ['GET /admin/address/list'],
					title: '收货地址',
					path: "/user/address",
					noCache: true
				}
			},
			{
				path: "collect",
				component: () => import("../views/user-manage/vip-collect.vue"), //会员收藏
				meta: {
					perms: ['GET /admin/collect/list'],
					title: '会员收藏',
					path: "/user/collect",
					noCache: true
				}
			},
			{
				path: "footprint",
				component: () => import("../views/user-manage/vip-track.vue"), //会员足迹
				meta: {
					perms: ['GET /admin/footprint/list'],
					title: '会员足迹',
					path: "/user/footprint",
					noCache: true
				}
			},
			{
				path: "history",
				component: () => import("../views/user-manage/seek-history.vue"), //搜索历史
				meta: {
					perms: ['GET /admin/history/list'],
					title: '搜索历史',
					path: "/user/history",
					noCache: true
				}
			},
			{
				path: "idea",
				component: () => import("../views/user-manage/idea-tickling.vue"), //意见反馈
				meta: {
					perms: ['GET /admin/idea/list'],
					title: '意见反馈',
					path: "/user/idea",
					noCache: true
				}
			},
		]
	},
	// 商场管理
	{
		path: "/mall",
		name: "Market-manage",
		component: () => import("../views/market-manage/Market-manage.vue"),
		meta: {
			title: '商场管理',
			path: "/mall"
		},
		children: [{
				path: "administrative",
				component: () => import("../views/market-manage/administrative.vue"), //行政区域
				meta: {
					perms: ['GET /admin/administrative/list', 'POST /admin/administrative/create',
						'GET /admin/administrative/read',
						'POST /admin/administrative/update', 'POST /admin/administrative/delete'
					],
					title: '行政区域',
					path: "/mall/administrative",
					noCache: true
				}
			},
			{
				path: "manufacturer",
				component: () => import("../views/market-manage/manufacturer.vue"), //品牌制造商
				meta: {
					perms: ['GET /admin/manufacturer/list', 'POST /admin/manufacturer/create',
						'GET /admin/manufacturer/read',
						'POST /admin/manufacturer/update', 'POST /admin/manufacturer/delete'
					],
					title: '品牌制造商',
					path: "/mall/manufacturer",
					noCache: true
				}
			},
			{
				path: "category",
				component: () => import("../views/market-manage/ItemCategory.vue"), //商品类目
				meta: {
					perms: ['GET /admin/category/list', 'POST /admin/category/create',
						'GET /admin/category/read', 'POST /admin/category/update',
						'POST /admin/category/delete'
					],
					title: '商品类目',
					path: "/mall/category",
					noCache: true
				}
			},
			{
				path: "order",
				component: () => import("../views/market-manage/indent-manage.vue"), //订单管理
				meta: {
					perms: ['GET /admin/order/list', 'GET /admin/order/detail', 'POST /admin/order/ship',
						'POST /admin/order/refund', 'POST /admin/order/delete', 'POST /admin/order/reply'
					],
					title: '订单管理',
					path: "/mall/order",
					noCache: true
				}
			},
			{
				path: "after",
				component: () => import("../views/market-manage/after-manage.vue"), //售后管理
				meta: {
					perms: ['GET /admin/after/list', 'POST /admin/after/create', 'GET /admin/after/read',
						'POST /admin/after/update', 'POST /admin/after/delete'
					],
					title: '售后管理',
					path: "/mall/after",
					noCache: true
				}
			},
			{
				path: "issue",
				component: () => import("../views/market-manage/general-issue.vue"), //通用问题
				meta: {
					perms: ['GET /admin/issue/list', 'POST /admin/issue/create', 'GET /admin/issue/read',
						'POST /admin/issue/update', 'POST /admin/issue/delete'
					],
					title: '通用问题',
					path: "/mall/issue",
					noCache: true
				}
			},
			{
				path: "antistop",
				component: () => import("../views/market-manage/antistop.vue"), //关键词
				meta: {
					perms: ['GET /admin/antistop/list', 'POST /admin/antistop/create',
						'GET /admin/antistop/read',
						'POST /admin/antistop/update', 'POST /admin/antistop/delete'
					],
					title: '关键词',
					path: "/mall/antistop",
					noCache: true
				}
			}

		]
	},

	// 商品管理
	{
		path: "/goods",
		name: "Commodity-manage",
		component: () => import("../views/commodity-manage/Commodity-manage.vue"),
		meta: {
			title: '商品管理',
			path: "/goods"
		},
		children: [{
				path: "list",
				component: () => import("../views/commodity-manage/commodity-list.vue"), //商品列表
				meta: {
					perms: ['GET /admin/goods/list', 'POST /admin/goods/delete'],
					title: '商品列表',
					path: "/goods/list",
					noCache: true
				}
			},
			{
				path: "create",
				component: () => import("../views/commodity-manage/commodity-putaway.vue"), //商品上架
				meta: {
					perms: ['POST /admin/goods/create'],
					title: '商品上架',
					path: "/goods/create",
					noCache: true
				}
			},
			{
				path: "comment",
				component: () => import("../views/commodity-manage/commodity-comment.vue"), //商品评论
				meta: {
					perms: ['GET /admin/comment/list', 'POST /admin/comment/delete'],
					title: '商品评论',
					path: "/goods/comment",
					noCache: true
				}
			}
		]
	},

	// 推广管理
	{
		path: "/promotion",
		name: "Spread-manage",
		component: () => import("../views/spread-manage/Spread-manage.vue"),
		meta: {
			title: '推广管理',
			path: "/promotion"
		},
		children: [{
				path: "ad",
				component: () => import("../views/spread-manage/advertising-manage.vue"), //广告管理
				meta: {
					perms: ['GET /admin/ad/list', 'POST /admin/ad/create', 'GET /admin/ad/read',
						'POST /admin/ad/update', 'POST /admin/ad/delete'
					],
					title: '广告管理',
					path: "/promotion/ad",
					noCache: true
				}
			},
			{
				path: "coupon",
				component: () => import("../views/spread-manage/discounts-manage.vue"), //优惠劵管理
				meta: {
					perms: ['GET /admin/coupon/list', 'POST /admin/coupon/create', 'POST /admin/coupon/update',
						'POST /admin/coupon/delete'
					],
					title: '优惠劵管理',
					path: "/promotion/coupon",
					noCache: true
				}
			},
			{
				path: "topic",
				component: () => import("../views/spread-manage/special-manage.vue"), //专题管理
				meta: {
					perms: ['GET /admin/topic/list', 'POST /admin/topic/create', 'GET /admin/topic/read',
						'POST /admin/topic/update', 'POST /admin/topic/delete'
					],
					title: '专题管理',
					path: "/promotion/topic",
					noCache: true
				}
			},
			{
				path: "grouponr",
				component: () => import("../views/spread-manage/group-rule.vue"), //团购规则
				meta: {
					perms: ['GET /admin/grouponr/list', 'POST /admin/grouponr/create',
						'POST /admin/grouponr/update', 'POST /admin/grouponr/delete'
					],
					title: '团购规则',
					path: "/promotion/grouponr",
					noCache: true
				}
			},
			{
				path: "groupona",
				component: () => import("../views/spread-manage/group-activity.vue"), //团购活动
				meta: {
					perms: ['GET /admin/groupona/listRecord'],
					title: '团购活动',
					path: "/promotion/groupona",
					noCache: true
				}
			},
			{
				path: "details",
				component: () => import("../views/spread-manage/discount-details.vue"), //优惠劵详情
				meta: {
					perms: ['GET /admin/details/list', 'POST /admin/details/create', 'POST /admin/details/update',
						'POST /admin/details/delete'
					],
					title: '优惠劵详情',
					path: "/promotion/details",
					noCache: true
				}
			},
			{
				path: "tjia",
				component: () => import("../views/spread-manage/special-tjia.vue"), //专题创建
				meta: {
					perms: ['GET /admin/tjia/list', 'POST /admin/tjia/create', 'POST /admin/tjia/update',
						'POST /admin/tjia/delete'
					],
					title: '专题创建',
					path: "/promotion/tjia",
					noCache: true
				}
			},
			{
				path: "bji",
				component: () => import("../views/spread-manage/special-bji.vue"), //专题编辑
				meta: {
					perms: ['GET /admin/bji/list', 'POST /admin/bji/create', 'POST /admin/bji/update',
						'POST /admin/bji/delete'
					],
					title: '专题编辑',
					path: "/promotion/bji",
					noCache: true
				}
			}
		]
	},
	// 系统管理
	{
		path: "/system",
		name: "System-manage",
		component: () => import("../views/system-manage/System-manage.vue"),
		meta: {
			title: '系统管理',
			path: "/system"
		},
		children: [{
				path: "admin",
				component: () => import("../views/system-manage/administrator.vue"), //管理员
				meta: {
					perms: ['GET /admin/admin/list', 'POST /admin/admin/create', 'POST /admin/admin/update',
						'POST /admin/admin/delete'
					],
					title: '管理员',
					path: "/system/admin",
					noCache: true
				}
			},
			{
				path: "notice",
				component: () => import("../views/system-manage/inform-manage.vue"), //通知管理
				meta: {
					perms: ['GET /admin/notice/list', 'POST /admin/notice/create', 'POST /admin/notice/update',
						'POST /admin/notice/delete'
					],
					title: '通知管理',
					path: "/system/notice",
					noCache: true
				}
			},
			{
				path: "log",
				component: () => import("../views/system-manage/operation-log.vue"), //操作日志
				meta: {
					perms: ['GET /admin/log/list'],
					title: '操作日志',
					path: "/system/log",
					noCache: true
				}
			},
			{
				path: "role",
				component: () => import("../views/system-manage/role-manage.vue"), //角色管理
				meta: {
					perms: ['GET /admin/role/list', 'POST /admin/role/create', 'POST /admin/role/update',
						'POST /admin/role/delete', 'GET /admin/role/permissions',
						'POST /admin/role/permissions'
					],
					title: '角色管理',
					path: "/system/role",
					noCache: true
				}
			},
			{
				path: "object",
				component: () => import("../views/system-manage/object-storage.vue"), //对象储存
				meta: {
					perms: ['GET /admin/object/list', 'POST /admin/object/create', 'POST /admin/object/update',
						'POST /admin/object/delete', 'GET /admin/object/permissions',
						'POST /admin/object/permissions'
					],
					title: '对象储存',
					path: "/system/object",
					noCache: true
				}
			}
		]
	},
	// 配置管理
	{
		path: "/configure",
		name: "Deploy-manage",
		component: () => import("../views/deploy-manage/Deploy-manage.vue"),
		meta: {
			title: '配置管理',
			path: "/configure",
		},
		children: [{
				path: "mall",
				component: () => import("../views/deploy-manage/market-deploy.vue"), //商场配置
				meta: {
					perms: ['GET /admin/configure/mall', 'POST /admin/configure/mall'],
					title: '商场配置',
					path: "/configure/mall",
					noCache: true
				}
			},
			{
				path: "freight",
				component: () => import("../views/deploy-manage/freight-deploy.vue"), //运费配置
				meta: {
					perms: ['GET /admin/configure/freight', 'POST /admin/configure/freight'],
					title: '运费配置',
					path: "/configure/freight",
					noCache: true
				}
			},
			{
				path: "order",
				component: () => import("../views/deploy-manage/indent-deploy.vue"), //订单配置
				meta: {
					perms: ['GET /admin/configure/order', 'POST /admin/configure/order'],
					title: '订单配置',
					path: "/configure/order",
					noCache: true
				}
			},
			{
				path: "wx",
				component: () => import("../views/deploy-manage/applet-deploy.vue"), //小程序配置
				meta: {
					perms: ['GET /admin/configure/wx', 'POST /admin/configure/wx'],
					title: '小程序配置',
					path: "/configure/wx",
					noCache: true
				}
			}
		]
	},
	// 统计报表
	{
		path: "/statistical",
		name: "statistical",
		component: () => import("../views/statistical/Statistical.vue"), //统计报表
		meta: {
			title: '统计报表',
			path: "/statistical",
		},
		children: [{
				path: "user",
				component: () => import("../views/statistical/user-statistics.vue"), //商品统计
				meta: {
					perms: ['GET /admin/statistical/user'],
					title: '用户统计',
					path: "/statistical/user",
					noCache: true
				}
			},
			{
				path: "indent",
				component: () => import("../views/statistical/indent-statistical.vue"), //商品统计
				meta: {
					perms: ['GET /admin/statistical/indent'],
					title: '订单统计',
					path: "/statistical/indent",
					noCache: true
				}
			},
			{
				path: "goods",
				component: () => import("../views/statistical/goods-statistical.vue"), //商品统计
				meta: {
					perms: ['GET /admin/statistical/goods'],
					title: '商品统计',
					path: "/statistical/goods",
					noCache: true
				}
			}
		]
	},
	// 外链
	{
		path: "/outside",
		name: "outside",
		component: () => import("../views/outside/Outside.vue"), //外链
		meta: {
			title: '外链',
			path: "/outside",
		},
		children: [
			{
				path: "txyun",
				component: () => import("../views/outside/txyun.vue"), //腾讯云
				meta: {
					perms: ['GET /admin/outside/txyun'],
					title: '腾讯云',
					path: "/outside/txyun",
					noCache: true
				}
			},
		]
	},
]



const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes: fixedRouter

})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
	return VueRouterPush.call(this, to).catch(err => err)
}
export default router
